package com.wei.ssm.service;

import com.wei.ssm.dao.IRoleDao;
import com.wei.ssm.dao.IpermissionDao;
import com.wei.ssm.domain.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class IPermissionService {

    @Autowired
    private IpermissionDao ipermissionDao;

    @Autowired
    private IRoleDao iRoleDao;

    public List<Permission> findAll() {
        return ipermissionDao.findAll();
    }

    public void save(Permission permission) {
        ipermissionDao.save(permission);
    }

    public void deleteById(int id) throws Exception{

//        删除角色跟权限
        iRoleDao.deletePermissonAndRoleById(id);
        //删除权限
        ipermissionDao.deleteById(id);
    }
}
